package com.tanglongan.designPattern.dp20_strategy.demo00.better.impl;

import com.tanglongan.designPattern.dp20_strategy.demo00.better.ICouponDiscount;

import java.math.BigDecimal;

/**
 * 直减优惠方式
 */
public class ZJCouponDiscount implements ICouponDiscount<Double> {

    @Override
    public BigDecimal discountAmount(Double couponInfo, BigDecimal skuPrice) {
        BigDecimal discountAmount = skuPrice.subtract(new BigDecimal(couponInfo));
        if (discountAmount.compareTo(BigDecimal.ZERO) < 1) return BigDecimal.ONE;
        return discountAmount;
    }

}
